(function () {
    var init;

    init = function () {
        var feed, background, renderer, clearAll, deletedVideosMemory;
        background = chrome.extension.getBackgroundPage();
        background = new background.Background();
        deletedVideosMemory = new DeletedVideosMemory();
        renderer = new FeedRenderer();
        feed = background.getFeed();
        renderer.render(feed);
        clearAll = document.getElementById('clear-all');
        clearAll.addEventListener('click', function (e) {
            var videoNodes, i;
            e.preventDefault();
            videoNodes = document.querySelectorAll("#feed .video a[id]");
            if (!videoNodes.length) {
                return;
            }
            for (i = videoNodes.length; i--;) {
                deletedVideosMemory.onVideoDeleted(videoNodes[i].id);
            }
            background.reload();
            renderer.render(feed);
        }, false);
    };

    addEventListener('load', init, false);
}());
